﻿@inherits Project.Engine.Control.BasePageRazor
@{
    ViewBag.Title = "Chỉnh sửa tài khoản";
    Layout = "~/Views/Backend/Home/_Master.cshtml";
    Project.Module.View.CMS.CMSEditTaiKhoan view = this.Model.DocumentObject as Project.Module.View.CMS.CMSEditTaiKhoan;
}
<h1>Chỉnh sửa tài khoản</h1>
<form method="post">
<table border="0">
    </tr>
    <tr>
        <td>Email</td>
        <td><input type="text" class="inp-form" id="mail" value="@view.employee.mail"/></td>
    </tr>
    <tr height="10px">
    </tr>
    <tr>
        <td>Thay đổi mật khẩu</td>
        <td><input type="password" class="inp-form" id="pass"/></td>
    </tr>
    <tr height="10px">
    </tr>
    <tr>
        <td>Xác nhận mật khẩu</td>
        <td><input type="password" class="inp-form" id="pass2"/></td>
    </tr>
    <tr height="10px">
    </tr>
</table>
     <div>
        <input type="submit" class="save-form" id="btnRegCMS" /> 
        <input type="submit" class="reset-form" id="btnCancel" />
    </div>
</form>

<script type="text/javascript">
    $('#btnRegCMS').click(function () {
        var link = '/admin/editAccount';
        var userId = window.location.href;
        var mail = document.getElementById('mail').value;
        var pass = document.getElementById('pass').value;
        var auPass = document.getElementById('pass2').value;

        if (pass.length > 0 && pass !== auPass) {
            alert("Password kô trùng nhau");
            return false;
        }

        $.post(link, {'id': userId, 'email': mail, 'pass': pass }, function (data) {
            if (data.result == 0) {
                window.location = "/admin/quan-ly-nhom-quyen";
            } else if (data.result == 1) {
                alert('Email không đúng định dạng!');
            } 
        });

        document.getElementById('mail').value = '';
        document.getElementById('pass').value = '';
        document.getElementById('pass2').value = '';

        // return
        return false;
    });

    $('#btnCancel').click(function () {
        document.getElementById('mail').value = '';
        document.getElementById('pass').value = '';
        document.getElementById('pass2').value = '';

        // return
        return false;
    });
</script>

